home *** CD-ROM | disk | FTP | other *** search
- /* Revision History:
-
- 93/03/22 aih
- - removed NotifyInit and its global variables
-
- 92/03/06 AIH
- - Modified to use vsprintf instead of sprintf, and changed last parameter
- in functions taking a variable argument list from "short" to "int" since
- the THINK C manual states that the last parameter should not be a type
- that hasn't been promoted.
-
- 91/05/08 AIH
- - Adapted to accept and return error codes from alert library
-
- 91/04/24 AIH
- - Added filter parameter to custom notification
-
- 91/04/01 AIH
- - Added a set of functions for displaying an alternate default notification
- alert
-
- 91/03/07, 91/03/11, 91/04/22 AIH
- - Modified for new way of calling alert library
-
- 91/01/05 Ari Halberstadt (AIH)
- - Inserted this standard header in all files */
-
- #include <stdarg.h>
- #include <string.h>
- #include <stdio.h>
- #include "AlertLib.h"
- #include "DialogLib.h"
- #include "NotifyLib.h"
- #include "ResourceLib.h"
- #include "ResourceConstantsLib.h"
- #include "StringLib.h"
-
- /* A general notification function. The parameters are:
-
- alert The ID of the alert to display.
- string The ID of the 'STR#' resource from which to get the format string
- to pass to sprintf.
- index The index to the string in the 'STR#' resource to use as the format string.
- icon The ID of the icon to display in the upper left corner.
- filter Filter function for the alert
- data Extra application defined data for the alert
- ... After the last button, further C string (character pointer)
- parameters may be given. These parameters will be passed to
- sprintf following the format string from the 'STR#' resource.
-
- These parameters allow you to use an alert template other than the one
- passed to NotifyInit. */
- static short NotifyGeneric(short alert, short string, short index,
- short icon, DlgModalFilterType filter, void *data, va_list args)
- {
- CStr255 fmt;
- CStr255 str;
- int len;
-
- ResStr(string, index, fmt);
- len = vsprintf(str, fmt, args);
- check(len != EOF && len < sizeof(str));
- return(AlertCustom(alert, icon, filter, data, 1, str));
- }
-
- short NotifyCustom(short alert, short string, short index, short icon,
- DlgModalFilterType filter, void *data, ...)
- {
- va_list ap;
- short item;
-
- va_start(ap, data);
- item = NotifyGeneric(alert, string, index, icon, filter, data, ap);
- va_end(ap);
- return(item);
- }
-
- void NotifyStop(int index, ...)
- {
- va_list ap;
-
- va_start(ap, index);
- (void) NotifyGeneric(RLA_OK, RLS_ALERT, index,
- stopIcon, NULL, NULL, ap);
- va_end(ap);
- }
-
- void NotifyNote(int index, ...)
- {
- va_list ap;
-
- va_start(ap, index);
- (void) NotifyGeneric(RLA_OK, RLS_ALERT, index,
- noteIcon, NULL, NULL, ap);
- va_end(ap);
- }
-
- void NotifyCaution(int index, ...)
- {
- va_list ap;
-
- va_start(ap, index);
- (void) NotifyGeneric(RLA_OK, RLS_ALERT, index,
- cautionIcon, NULL, NULL, ap);
- va_end(ap);
- }
-
- short NotifyOtherStop(int index, ...)
- {
- va_list ap;
- short item;
-
- va_start(ap, index);
- item = NotifyGeneric(RLA_OK_CANCEL, RLS_ALERT, index,
- stopIcon, NULL, NULL, ap);
- va_end(ap);
- return(item);
- }
-
- short NotifyOtherNote(int index, ...)
- {
- va_list ap;
- short item;
-
- va_start(ap, index);
- item = NotifyGeneric(RLA_OK_CANCEL, RLS_ALERT, index,
- noteIcon, NULL, NULL, ap);
- va_end(ap);
- return(item);
- }
-
- short NotifyOtherCaution(int index, ...)
- {
- va_list ap;
- short item;
-
- va_start(ap, index);
- item = NotifyGeneric(RLA_OK_CANCEL, RLS_ALERT, index,
- cautionIcon, NULL, NULL, ap);
- va_end(ap);
- return(item);
- }
-